<template>
    <div class="patent-details-box">
        <van-nav-bar title="专利信息" left-text="返回" left-arrow @click-left="onClickLeft" />

        <van-collapse v-model="activeNames" :accordion="true">
			<van-collapse-item name="1">
				<template slot="title">
					订单信息
				</template>
				<template slot="value">
					查看详情
				</template>
				<template slot="default">
                    <!-- <viewOrderTemplate :dataResouce="details" :pageDataList="defaultLabelList"></viewOrderTemplate> -->
                    <viewOrderTemplate :dataResouce="dataResouce" pageDataList="defaultLabelList"></viewOrderTemplate>
				</template>
			</van-collapse-item>
		</van-collapse>
    </div>
</template>

<script>
import viewOrderTemplate from '~/components/_viewOrder'
export default {
    data() {
        return {
            details: {},
            activeNames: '1',
            dataResouce: [],
            defaultLabelList: ['订单编号', '专利名称', '专利类型', '专利权人', '发明人', '申请号', '订单状态', '提交时间', '受理通知书'],
        }
    },
    created() {
        this.getCurrentOrderList()
    },
    //缓存也会走的钩子
    deactivated(){
        this.$destroy(true);//销毁组件
    },
    //缓存也会走的钩子
    activated() {
        this.getCurrentOrderList()
    },
    methods: {
        getCurrentOrderList() {
            let id = this.$route.params.id
            this.$axios.get(`api/finals/${id}/show`).then(res => {
                if(res.data.code == 200){
                    this.details = res.data.data

                    // s实用新型  w外观设计 f发明专利
                    let patentType = ''
                    if(this.details.type === 'F' && this.details.type !== null){
                        patentType = '发明专利'
                    }else if(this.details.type === 'W' && this.details.type !== null){
                        patentType = '外观设计'
                    }else{
                        patentType = '实用新型'
                    }
                    this.dataResouce = [
                        { label: '订单编号', value: this.details.order_number },
                        { label: '专利名称', value: this.details.name },
                        { label: '专利类型', value: patentType },
                        { label: '专利权人', value: this.details.order.patent_user },
                        { label: '发明人', value: this.details.order.user_name },
                        { label: '申请号', value: this.details.application_number },
                        { label: '订单状态', value: this.details.status },
                        { label: '受理通知书', value: this.details.acceptance_note_file },
                    ]
                }else{
                    this.$toast('请求错误');
                }
            })
        },
        onClickLeft() {
            this.$router.go(-1);
        }
    },
    components: {
        viewOrderTemplate
    }
}
</script>

<style lang="less" scoped>
    .patent-details-box{
        height: 100%;
        background: white;
        
        /deep/ .van-collapse-item__content{
			padding: 0;
		}

		/deep/ .van-cell__right-icon{
			display: none;
		}
    }
</style>